package com.gyx.lottery.dao.mapper;

import com.gyx.lottery.dao.dataobject.PrizeDO;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface PrizeMapper {
@Insert("insert into prize (name,description,price,image_url) values (#{name},#{description},#{price},#{imageUrl})")
@Options(useGeneratedKeys = true,keyProperty = "id",keyColumn = "id")
    Long insert(PrizeDO prizeDO);
@Select("select count(*) from prize")
    int count();
@Select("select * from prize order by id desc limit #{offset},#{pageSize}")
    List<PrizeDO> selectPrizeListByPage(@Param("offset")int offset,@Param("pageSize") int pageSize);
@Select("<script>" +
        " select id from prize where id in " +
        "<foreach item='item'  collection='items' open='(' separator=',' close=')'> " +
        " #{item}"+
        " </foreach>"+
        " </script> "
)
    List<Long> findIdByIds(@Param("items") List<Long> prizeIds);

    @Select("<script>" +
            " select * from prize where id in" +
            " <foreach item='item' collection='items' open='(' separator=',' close=')' >" +
            " #{item}" +
            " </foreach>" +
            " </script>")
    List<PrizeDO> batchSelectById(@Param("items")List<Long> prizeIds);
    @Select("select * from prize where id=#{id}")
    PrizeDO selectById(@Param("id") Long id);
}
